
package JET.graphics.elements;

import JET.geom.Vec2d;
import JET.graphics.GraphicPanel;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.Line2D;

/**
 *
 * @author raos
 */
public class DrawableLine implements SceneDrawable {

    public double x1=0,y1=0,x2=0,y2=0;
    public Color color = Color.BLACK;

    public DrawableLine(double x1, double y1, double x2, double y2) {
        this.x1 = x1;
        this.y1 = y1;
        this.x2 = x2;
        this.y2 = y2;
    }
    public DrawableLine(Vec2d a, Vec2d b) {
        this.x1 = a.x;
        this.y1 = a.y;
        this.x2 = b.x;
        this.y2 = b.y;
    }

    public void draw(Graphics g, GraphicPanel gp) {
        double x1 = gp.engineToScrX( this.x1 );
        double y1 = gp.engineToScrY( this.y1 );
        double x2 = gp.engineToScrX( this.x2 );
        double y2 = gp.engineToScrY( this.y2 );

        Graphics2D g2d = (Graphics2D)g;
        g.setColor( color );
        g2d.draw( new Line2D.Double(x1, y1, x2, y2) );
    }
}
